﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BonsaiScrum.Core.Command;
using BonsaiScrum.Bus;
using BonsaiScrum.Core.Domain;
using BonsaiScrum.Core.Persistance;

namespace BonsaiScrum.Core.CommandHandlers
{
    public class DropProjectHandler : ICommandHandler<DropProject>
    {
        private IDomainRepository _domainRepository;

        public DropProjectHandler(IDomainRepository domainRepository)
        {
            _domainRepository = domainRepository;
        }

        public void Handle(DropProject message)
        {
            var user = _domainRepository.GetById<User>(message.ManagerThatIsDroppingProjectId);
            var project = _domainRepository.GetById<Project>(message.ProjectId);

            var manager = user.GetRole<Manager>();
            manager.Drop(project);
        }
    }
}
